//package com.gk.panda.apis.util;
//
//import com.gk.fdfs.FastdfsService;
//import org.csource.common.FastdfsException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.IOException;
//import java.util.Base64;
//
//public class FileUtil {
//
//    @Autowired
//    private static FastdfsService fastdfsService;
//
//    public static String upload(MultipartFile file) throws IOException, FastdfsException {
//        String filename = file.getOriginalFilename();
//        byte[] fileBytes = file.getBytes();
//        String[] result = fastdfsService.uploadFile(fileBytes, filename);
//        byte[] bytes = (result[0] + "/" + result[1]).getBytes();
//        return Base64.getEncoder().encodeToString(bytes);
//    }
//
//    public static void delete(String path) throws IOException, FastdfsException {
//        String str = new String(Base64.getDecoder().decode(path));
//        int index = str.indexOf("/");
//        String group = str.substring(0,index);
//        String storagePath = str.substring(index + 1);
//        fastdfsService.deleteFile(group,storagePath);
//    }
//}
